<template lang="html">
	<div class="a">				
	   <van-nav-bar
		  left-arrow
		  @click-left="link('/')"
		  style="background: #ffd630;"
		>		
			<van-icon name="arrow-left" slot="left" color="#333"  size="20"/>
			<div slot="title" class="weight_header">
				管理
			</div>
	  </van-nav-bar>	
	  
	  
      <floor7></floor7>	

	  <div class="b">
	  	
	  	<div class="b_1">
           <van-cell  is-link style="padding-top:0 ;padding-bottom: 0;" @click="link('/market/withdrawal/index')">
           	  <div slot="title" style="display: flex;align-items: center;">
           	  	 <span style="font-size: 15px;color: #333;font-weight: 500;">我的集市账户</span>
           	  	 <span style="font-size: 12px;color: #333;font-weight: 500;">(余额: {{money}}元)</span>
           	  </div>
           	  <div slot="icon" style="display: flex;align-items: center;">
           	  	  <img src="../../../../static/img/lanhu/68.png" alt="" style="width: 18px;height: 18px;margin-right: 6px;display: block;"/>
           	  </div>
           </van-cell>
	  	</div>	  	
	  	
	  	
	  	
	  	
        <div class="floor1" @click="linkList(0)">
        	<div class="title">
        		我发布的
        		<span>{{releaseList.total}}</span>
        	</div>
        	<div class="container" v-if="releaseList.total>0">
        		<div class="goodsList">
        			<!--@click="linkPreview(item)"-->
        			<div v-for="(item,index) in releaseList.list">
        				<img :src="item.goodsImage" alt="" />
        			</div>
        		</div>       		
        		<div class="more" ><van-icon name="ellipsis" size="20" color="#999"/></div>
        	</div>
        </div>
        
        
        
        <div class="floor1" @click="link('/market/list/sellOut')">
        	<div class="title">
        		我卖出的
        		<span>{{sellList.total}}</span>
        	</div>
        	<div class="container" v-if="sellList.total>0">
        		<div class="goodsList">
        			<div v-for="(item,index) in sellList.list"><img :src="item.goodsImage" alt="" /></div>
        		</div>
        		<div class="more" ><van-icon name="ellipsis" size="20" color="#999"/></div>
        	</div>
        </div>
        
        <van-cell  is-link :title="myBuyTitle" style="margin-top: 10px;" @click="link('/market/list/myBuy')">

        </van-cell>
       
	    <van-cell  is-link :title="myCollection" style="margin-top: 10px;" @click="link('/market/list/myCollection')">

	    </van-cell>       
       
	    <van-cell  is-link :title="myBrowsedTitle" style="margin-top: 10px;" @click="link('/market/list/Browsed')">

	    </van-cell>         
	  </div>
	  <Footer ref="footer"></Footer>  
	  <div style="height: 50px;"></div>
	</div>
</template>                                                                

<script>	
import Floor7 from '_c/market/floor/floor07.vue'		
import Footer from '_c/market/newFoot'
import {getFun} from '@/api/publicFun.js'	 
let publicFun=getFun()
export default {
	name: 'MarketMe',
	components: {
	    Footer,Floor7
	},	
	data() {
       return {
       	   userId:'',
           url1:this.$api+'/marketorderservice/api/v1/market/findReleaseList',  // 发布列表
           url3:this.$api+'/marketorderservice/api/v1/market/findSellList',     // 卖出列表
           url2:this.$api+'/marketorderservice/api/v1/market/findMarketMoney/', // 获取账户余额            
           url4:this.$api+'/marketorderservice/api/v1/market/findMyCollectionCount',// 获取收藏数量
           url5:this.$api+'/marketorderservice/api/v1/market/findMyGoodsLookCount', // 获取浏览数量
           url6:this.$api+'/marketorderservice/api/v1/market/findBuyGoodsCount', // 获取我买到的数量
           money:'',  // 账户余额
           releaseList:{},   // 记录发布列表
           sellList:{},       // 记录卖出列表
           myBuyTitle:'我买到的',
           myCollection:'我收藏的',
           myBrowsedTitle:'我浏览的'         
       }
	},
	methods: {
		// 截图前面3条
		splitArr(arr){
			let newArr=[]
			for(var i=0;i<arr.length;i++){
			   if(i<=2){
			   	 newArr.push(arr[ i])
			   }
			}
			return newArr
		},	
		// 跳转到列表页
		linkList(num){
			switch(num) {
		     case 0:
		        this.link('/market/list/myRelease')
		        break;					 
			} 				
		},
		// 跳转到商品详情页
		linkPreview(item){
  			let arg='[{"comId":"'+item.comId+'"}]' 
  			this.link('/market/goods/preview',arg)			
		},
		// 获取账户余额
		getMoney(){
		  let that=this
		  this.$Axios2.Get(this.url2+this.userId).then(function(res) {
		  	if(res.data.money){
		  		that.money=res.data.money.toFixed(2)
		  	}else{
		  		that.money='0.00'
		  	}
		  })			
		},
		getReleaseList(){
		  let that=this
		  let params={
		  	userId:this.userId
		  }
		  this.$Axios2.Post(this.url1,params).then(function(res) {
            that.releaseList=res.data.page
            that.releaseList.list=that.splitArr(res.data.page.records)
		  })				
		},
		getSellList(){
		  let that=this
		  let params={
		  	userId:this.userId
		  }
		  this.$Axios2.Post(this.url3,params).then(function(res) {
            that.sellList=res.data.page
            that.sellList.list=that.splitArr(res.data.page.records)
		  })			
		},
		numInfo(){
		  let that=this
		  this.$Axios2.Get(this.url4+'/'+this.userId).then(function(res) {
             that.myCollection+='('+res.data+')'
		  })
		  this.$Axios2.Get(this.url5+'/'+this.userId).then(function(res) {
             that.myBrowsedTitle+='('+res.data+')'
		  })
		  this.$Axios2.Get(this.url6+'/'+this.userId).then(function(res) {
             that.myBuyTitle+='('+res.data+')'
		  })		  
		}
	},
	beforeRouteEnter(to, from, next) {
	  next(vm=>{
	  	 vm.$refs.footer.interval()
	  })
	},
	beforeRouteLeave(to, from, next) {
	  this.$refs.footer.clear()
	  next();
	},		
	mixins:[publicFun],//混入
	mounted() {
		this.userId=this.$router.currentRoute.query.userId	 
		this.getMoney()
		this.getReleaseList()
		this.getSellList()
		this.numInfo()
	}
}
</script>

<style scoped lang="scss">
.a{background: #faf7fa;min-height: 100%;width: 100%;position: absolute;}
.a *{box-sizing: border-box;}	

.b{margin-top: -30px;padding: 0 15px 30px}
.b .b_1{background: #fff;border-radius: 15px;font-size: 16px;color: #333;font-size: 15px;
display: flex;padding: 15px 0;justify-content: space-around;}
.b .b_2{background: #fff;border-radius: 10px;margin-top: 10px;}
.b_2 img{width: 100%;border-radius: 10px;display: block;}
.floor1{
	margin-top: 10px;padding: 15px 20px;background: #fff;border-radius: 10px;
	.title{color: #666;font-size: 15px;}
	.container{display: flex;margin-top: 14px;justify-content: space-between;
	  .goodsList{width: 78%;display: flex;justify-content: flex-start;
	    div{width: 33.3%;display: flex;justify-content: center;align-content: center;
	      img{height: 70px;display: block;border-radius: 8px;width: 70px;}
	    }
	    
	  }	  
	  .more{display: flex;align-items: center;justify-content: center;flex: 1;}
	}	
}
.van-nav-bar__title{font-weight: bold;}
</style>